import { Toast } from 'vant';
import { Stepper } from 'vant';
import { scrollMixin } from "utils/mixin";
export default {
    mixins: [scrollMixin], //加载更多
  data() {
    return {
      uniacid1: localStorage.getItem('uniacid'),
      //余额
      member_credit2: 0.0,
      //余额字样
      balanceLang: '团拼奖',
      income_name_text: "",
      show: false,
      dataInfo: {
        balance_button: [],
        balance_log: []
      }, //保存信息
      name: false,
      Navlis: 'day',
      nameOther: [],
      point_statistics: '',
      uniacid: '',
      isBank: 0,//赢广宝54--限制互转 0可以互转 1不可以互转
      isTixian: 0,//赢广宝54--限制提现 0可以提现 1不可以提现
      duihuanPop: false,//换牛二期-88-兑换积分弹窗
      niuJifen: 699,//换牛二期-88-兑换积分数量
      niuJifenNum: 699,//换牛二期-88-兑换1份积分数量
      isNiuDuiLoadding: false,//换牛二期-88-兑换积分-重复点击
      fenNiuJifen: 1,//换牛二期-88-兑换积分份数
      duihuanFirstPop: false,//换牛二期-88-兑换积分-输入会员id
      duihuanSecondPop: false,//换牛二期-88-兑换积分-确认会员id
      niuUid: '',//换牛二期-88-兑换积分-会员id
      point: 0, //团拼奖
      tuanpinList: [], //团拼奖列表
      page: 1, //团拼奖列表页数
      total_page: 0, //团拼奖列表总条数
      isLoadMore: false, //是否加载更多
    };
  },
  mounted() {
    console.log(this.$route.query.i, 'routerrrrrrrrr', window.location.href);
    this.uniacid = this.$route.query.i;
    this.getDataPoint();
    // this.point = this.$route.params.point ? this.$route.params.point : window.localStorage.getItem('tuanpin_point');
    // localStorage.setItem("uniacid", this.uniacid)
  },
  methods: {
    toWithdrawals(){
        this.$router.push(this.fun.getUrl("tuanPinWithdrawals", { point: this.point }))
    },
    getDataPoint() {
       var that = this;
        $http.post("shijiahe.my_asset", { 
            uid: localStorage.getItem("uid") ? localStorage.getItem("uid") : localStorage.getItem("mid")
        }).then(res => {
            if (res.result == 1) {
                var obj = res.data;
                console.log(res.data,'我的资产')
                that.point = obj.tuanpin ? obj.tuanpin : 0;//团拼
            }
            
        });
    },
    getData() {
      var that = this;
      $http
        .get(
          "shijiahe.tuanpin_mingxi",
          {
            uid:  window.localStorage.getItem("uid") ? window.localStorage.getItem("uid") : '',
            page: this.page,
          },
          "加载中..."
        )
        .then(
          (response) => {
            if (response.result === 1) {
            
            this.isLoadMore = true;
            this.total_page = response.data.last_page;
            if (!this.total_page) {
                this.total_page = 0;
            }
                this.tuanpinList = response.data.data;
            } else {
                this.isLoadMore = false; // 防止多次请求分页数据
                this.tuanpinList = [];
            }
          },
          function (response) {
            this.$dialog.alert({ message: response.msg });

          }
        );
        
    },
    //获取更多数据
    getMoreData() {
      if (!this.isLoadMore) return;
      this.isLoadMore = false; // 防止多次请求分页数据
      if (this.page >= this.total_page) {
        return;
      } else {
        this.page += 1;
        let json = {
            uid: window.localStorage.getItem("uid") ? window.localStorage.getItem("uid") : '',
            page: this.page
        };
        $http.post("shijiahe.tuanpin_mingxi", json, "加载中").then(response => {
          if (response.result === 1) {
            var nextPageData = response.data.data;
            this.tuanpinList = [...this.tuanpinList,...nextPageData];
            this.isLoadMore = true;
          } else {
            this.page = this.page - 1;
            this.isLoadMore = false;
          }
        });
      }
    },
  },
  activated() {
    
    this.getData();
  }
};